using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

using System;
using System.Runtime.Serialization;


namespace Agron.Data.Contracts
{
    /// <summary>
    /// Defines the data contract for a User Profile.
    /// </summary>
    [Serializable]
    [DataContract(Namespace = "http://schemas.udlap.mx/Agron/UserProfile")]
    public class UserProfile
    {
        private Guid _userId;
        private string _email;
        private string _displayName;
        private string _username;

        /// <summary>
        /// Initializes a new instance of the <see cref="UserProfile"/> class.
        /// </summary>
        public UserProfile() { }

        /// <summary>
        /// Gets or sets the user id.
        /// </summary>
        /// <value>A <see cref="Guid"/> that contains the user id.</value>
        [DataMember(IsRequired = true)]
        public Guid UserId { get { return this._userId; } set { this._userId = value; } }

        /// <summary>
        /// Gets or sets the e-mail address.
        /// </summary>
        /// <value>A <see cref="String"/> that contains the e-mail address.</value>
        [DataMember(IsRequired = true)]
        [NotNullValidator(MessageTemplateResourceName = "UserProfileEmailRequired", MessageTemplateResourceType = typeof(Properties.Resources))]
        [StringLengthValidator(1, 150, MessageTemplateResourceName = "UserProfileEmailRequired", MessageTemplateResourceType = typeof(Properties.Resources))]
        [RegexValidator(@"^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$",
            MessageTemplateResourceName = "UserProfileEmailRegex",
            MessageTemplateResourceType = typeof(Properties.Resources))]
        public string Email { get { return this._email; } set { this._email = value; } }

        /// <summary>
        /// Gets or sets the display name.
        /// </summary>
        /// <value>A <see cref="String"/> that contains the display name.</value>
        [DataMember(IsRequired = true)]
        [NotNullValidator(MessageTemplateResourceName = "UserProfileDisplayNameRequired", MessageTemplateResourceType = typeof(Properties.Resources))]
        [StringLengthValidator(1, 100, MessageTemplateResourceName = "UserProfileDisplayNameRequired", MessageTemplateResourceType = typeof(Properties.Resources))]
        public string DisplayName { get { return this._displayName; } set { this._displayName = value; } }

        /// <summary>
        /// Gets or sets the name of the user.
        /// </summary>
        /// <value>A <see cref="string"/> that contains the name of the user.</value>
        [DataMember(IsRequired = true)]
        public string Username { get { return this._username; } set { this._username = value; } }
    }
}